package com.groupbuying.cheetah.withdrawal;

import com.groupbuying.cheetah.common.PageUtils;
import com.groupbuying.cheetah.common.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/withdrawal")
public class GetWithdrawalListController {
    @Autowired
    private GetWithdrawalListDao getWithdrawalListDao;
    /**
     * 获取提现列表
     * @author cuich
     * @date 2019年7月31日18:41:16
     */
    @GetMapping("/getWithdrawalList")
    public PageUtils listWithStoreInfo(@RequestParam Map<String,Object> params) {
        params.put("gmtCreateStart", params.get("startTime"));
        params.put("gmtCreateEnd", params.get("endTime"));
        Query query = new Query(params);
        List<Map<String,String>> resultList = getWithdrawalListDao.getWithdrawalList(query);
//        提现状态:待审核-WAIT-0,提现成功-SUC-1,提现失败-FAIL-2,提现异常-EXC-3
        for(Map<String,String> list:resultList){
            String withdrawal_state = list.get("withdrawal_state");
            if("0".equals(withdrawal_state)){
                list.put("withdrawal_state","待审核");
            }else if("1".equals(withdrawal_state)){
                list.put("withdrawal_state","提现成功");
            }else if("2".equals(withdrawal_state)){
                list.put("withdrawal_state","提现失败");
            }else{
                list.put("withdrawal_state","提现异常");
            }
        }
        int total = getWithdrawalListDao.count(params);
        PageUtils pageUtils = new PageUtils(resultList, total);
        return pageUtils;

    }
}
